home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / proc / machTypeSymm.c < prev    next >
C/C++ Source or Header  |  1991-03-16  |  3KB  |  101 lines

  1. /* 
  2.  * machTypeSymm.c --
  3.  *
  4.  *    Contains the machine specific routine for determining if
  5.  *      a file is an object file for a Sun 2 or a Sun 3.
  6.  *
  7.  * Copyright 1989 Regents of the University of California
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  */
  16.  
  17. #ifndef lint
  18. static char rcsid[] = "$Header: /sprite/src/attcmds/file/RCS/machTypeSymm.c,v 1.3 90/10/24 22:29:40 shirriff Exp Locker: shirriff $";
  19. #endif /* not lint */
  20.  
  21. #include <symm.md/sys/exec.h>
  22. #include "file.h"
  23.  
  24.  
  25. /*
  26.  *----------------------------------------------------------------------
  27.  *
  28.  * machTypeSymm --
  29.  *
  30.  *    Determine if the file is a Symm-specific file type.
  31.  *
  32.  * Results:
  33.  *    If successful, return the name of the machine.  Otherwise
  34.  *      return NULL.
  35.  *
  36.  * Side effects:
  37.  *    Modifies the `magic' number.
  38.  *
  39.  *----------------------------------------------------------------------
  40.  */
  41.  
  42. char *
  43. machTypeSymm(bufferSize, buffer, magic, syms, other)
  44.     int        bufferSize;    /* size of buffer */
  45.     char    *buffer;    /* buffer containing header */
  46.     int         *magic;         /* pointer to magic number */
  47.     int         *syms;          /* pointer to symbols */
  48.     char    **other;    /* other information to return */
  49. {
  50.  
  51.     struct exec        *header;
  52.     char        swappedHeader[sizeof(*header) * 2];
  53.     int            swappedSize = sizeof(swappedHeader);
  54.     int            status;
  55.  
  56.     *other = "";
  57.  
  58.     if (bufferSize < sizeof(struct exec)) {
  59.     return NULL;
  60.     }
  61.     header = (struct exec *) buffer;
  62.     if (header->a_magic == OMAGIC) {
  63.     *magic = 0407;
  64.     *syms = header->a_syms;
  65.     return "symm";
  66.     } else if (header->a_magic == ZMAGIC) {
  67.     *magic = 0413;
  68.     *syms = header->a_syms;
  69.     return "symm";
  70.     } else if (header->a_magic == SMAGIC) {
  71.     *magic = 0413;
  72.     *syms = header->a_syms;
  73.     return "Dynix symm";
  74.     }
  75.     if (FMT_SYM_FORMAT != hostFmt) {
  76.     status = Fmt_Convert("{h2w7}", FMT_SYM_FORMAT, &bufferSize, 
  77.             (char *) buffer, hostFmt, &swappedSize, swappedHeader);
  78.     if (status) {
  79. #ifndef KERNEL
  80.         fprintf(stderr, "Fmt_Convert returned %d.\n", status);
  81. #endif
  82.         return NULL;
  83.     }
  84.     header = (struct exec *) swappedHeader;
  85.     if (header->a_magic == OMAGIC) {
  86.         *magic = 0407;
  87.         *syms = header->a_syms;
  88.         return "symm";
  89.     } else if (header->a_magic == ZMAGIC) {
  90.         *magic = 0413;
  91.         *syms = header->a_syms;
  92.         return "symm";
  93.     } else if (header->a_magic == SMAGIC) {
  94.         *magic = 0413;
  95.         *syms = header->a_syms;
  96.         return "Dynix symm";
  97.     }
  98.     }
  99.     return NULL;
  100. }
  101.